package b1.scenes.main
{
	import b1.net.*;
	import b1.players.*;
	import b1.scenes.*;
	import b1.scenes.crime.*;
	import b1.scenes.detect.*;
	import b1.scenes.home.Home;
	import b1.utils.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;
	import flash.ui.Mouse;
	import flash.external.*;

	public class SingleEntry extends Sprite
	{
		private const bgImageStrs:Array = ["CrimeEntry", "DetectEntry", "HomeEntry"];
		private const entryStrs:Array = ["作案", "探案", "回家"];
		private var entryIndex:int;
		private var bubble:ThoughtBubble;
		
		public function SingleEntry(entryIndex:int)
		{
			super();
			this.entryIndex = entryIndex;
			//背景图片
			var BackgroundImage:Class = ResourceHelper.getInstance().getClassByName(bgImageStrs[entryIndex]);
			var backgroundImage:Sprite = new BackgroundImage();
			addChild(backgroundImage);
			//入口文字
			bubble = new ThoughtBubble(entryStrs[entryIndex]);
			bubble.x = 50;
			bubble.y = -200;
			addChild(bubble);
			//侦听事件
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		private function onMouseClick(event:MouseEvent):void
		{
			var homeType:int;
			//作案
			if (entryIndex == 0)
			{
				homeType = 3;
			}
			//探案
			else if (entryIndex == 1)
			{
				homeType = 4;
			}
			//回家
			else
			{
				homeType = 0;
			}
			var home:Home = new Home(PlayerInfoHelper.getInstance().userId, homeType);
			SceneContainer.getInstance().loadScene(home);
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			this.filters = [new GradientGlowFilter(0, 45, [0x72D52C, 0x72D52C], [0, 1], [0, 255], 10, 10, 2, BitmapFilterQuality.HIGH, BitmapFilterType.OUTER)];
			Mouse.cursor = "button";
			bubble.mouseOver();
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			this.filters = null;
			Mouse.cursor = "auto";
			bubble.mouseOut();
		}
		
	}
}